package com.heifei.day03

/**
 * @author caizhengjun
 * @date 2020/8/6 3:56 下午
 */
object WordCount {

  def main(args: Array[String]): Unit = {

    val lines = List("Hello Tom Hello Jerry", "Hello Tom Jerry", "Hello Hello Jerry")

    //val unit = lines.flatMap(_.split(" ")).map((_, 1)).groupBy(_._1).map(s => (s._1, s._2.size)).toList.sortBy(_._2)

    //println(unit)


    val unit = lines.flatMap(_.split(" ")).map((_, 1)).groupBy(_._1).map(s => (s._1, s._2.size)).toList.sortBy(_._2)

    println(unit)


  }
}
